package com.mls.fivedistrict.controller.portal;

import com.github.pagehelper.PageInfo;
import com.mls.fivedistrict.common.ServiceResponse;
import com.mls.fivedistrict.controller.BaseController;
import com.mls.fivedistrict.pojo.Integral;
import com.mls.fivedistrict.server.IntegralService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by chenxiuxiang on 2018/5/20.
 */
@RestController("integralControllerPortal")
@RequestMapping("/api/app")
public class IntegralController extends BaseController {
    @Autowired
    IntegralService integralService;

    @GetMapping("/v1/integrals")
    public ServiceResponse getIntegralList() {
        List<Integral> transferIntegralList = integralService.getTransferIntegralList(getPageFilter(),getUser().getId());
        PageInfo pageInfo = new PageInfo(transferIntegralList);
        return ServiceResponse.createSuccessResponse(pageInfo);
    }

    @GetMapping("/v1/reward/integrals")
    public ServiceResponse getCanRewardIntegralList() {
        List<Integral> canPayIntegralList = integralService.getCanRewardIntegralList(getPageFilter(),getUser().getId());
        PageInfo pageInfo = new PageInfo(canPayIntegralList);
        return ServiceResponse.createSuccessResponse(pageInfo);
    }

}
